Image Processing:
    General Handling | Import / Export | Viewing | Geometrical Transformations | Color Manipulations |

    IMPORT AND EXPORT OF IMAGES

    - Xi and file formats -

    Xi is capable to read or write the following image file types (based on the netpbm tools, libtiff and libjpeg)

    Format Parameters for writing
    PPM bin
    PGM bin
    PBM bin
    BMP os2
    GIF interlace, transparent, unsorted
    TIFF none, packbits, lzw, fax3, fax4, fill_msb2lsb, fill_lsb2msb, d2, fill
    TARGA mono, cmap, rgb, norle
    JPEG quality

    To read the GIF file "test.gif" form the current directory type

    (  1)>image=read_gif("test.gif");
    
    The image will be stored in the [k,l,3] dimensional array image using the RGB color system. Hereby k the number of rows und l the number of columns of the image test.gif. The syntax for the other formats are strait forward i.e.
    (  2)>image=read_targa("test.tga");
    
    - with one exception. To read files of the formats PPM, PGM and PBM use the function read_pnm. It will automaticly detect the correct file format.
    (  3)>image=read_pnm("test.pgm");
    
    To store this image in a GIF file type
    (  4)>write_gif("first.gif",image);
    
    Hopefully you have write permissions to the current directory. If you will write a colormap based image like this
    (  5)>picture={ {0,0,1,0,0},{0,2,0,3,0},{4,0,0,0,4},{0,3,0,2,0},{0,0,1,0,0} };
    (  6)>colormap={ {0,0,0}, {10,10,10}, {150,0,150}, {0,150,0}, {0,0,240} };
    
    to the GIF file first.gif give both parameters to the write statement.
    (  7)>write_gif("first.gif", picture, colormap);
    
    Treat the other file formats in the same way. Keep in mind though that you cannot write a PNM file. This format exists for reading the formats PPM, PGM and PBM only.

    Let's discribe the parameters of the file formats step by step. (Reading an image Xi automatically detects the different parameters. Therefore only when writing an image knowledge of the parameters is required.

    Normally PPM, PGM and PBM are plain ASCII files. Parameter bin instructs Xi to make a binary file. This will save a lot of diskspace.

    (  8)>write_ppm("first.gif", image, \bin)
    
    Maybe you want to read a BMP file for using it with the operating system OS/2. Use the parameter os2 to avoid incompatibility.

    The parameter interlace tells Xi to produce an interlaced GIF file. transparent marks a given color as transparent in a GIF file

    (  9)>write_gif("first.gif", image, \transparent={0,0,0})
    
    and the parameter sort produces a sorted colormap.

    The none, packbits, lzw, fax3 and fax4 options are used to override the default and set the compression scheme for TIFF files. The CCITT Group 3 (fax3) and Group 4 (fax4) compression algorithms can only be used with bilevel data. For fax3 2d requests 2-dimensional encoding, while fill requests each encoded scanline to be zero-filled to a byte boundary. If you want to change the default fill order from msb-to-lsb to lsb-to-msb use the parameter msb2lsb or lsb2msb.

    The parameter mono forces TARGA file to be of type 8 bit monochrome whereas cmap requests a TARGA file to be of type 24 bit colormapped and rgb forces TARGA file to be of type RGB. To disable run-length encoding use the parameter norle.

    Obviously the parameter quality controls the quality of a JPEG image. This parameter is helpful for saving diskspace.


    Rechts Index Index Index Linls © 1995 by Bodo Junglas, Klaus Spanderen and Fabian Weis
    - Last revised: April 23 1996